/***************************************************************************
 *   Copyright (C) 2007, 2008, 2009 by Lasse Liehu                         *
 *   lliehu@kolumbus.fi                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef LOGWIDGET_H
#define LOGWIDGET_H

#include <QWidget>

#include "ui_logwidget.h"

class QTextBrowser;
class QShowEvent;
class QCloseEvent;

// Comment this if you don't want this class to depend on
// SavingOfSettingsDisabledInfo
#define LOGWIDGET_USESAVINGOFSETTINGSDISABLEDINFO

/**
 * @attention When using this class remember to set correct organization and
 *     application names using QCoreApplication::organizationName() and
 *     QCoreApplication::applicationName(). These will be used to save settings
 *     to the right place and also to show correct application name in the
 *     window titles of various windows.
 */
class LogWidget : public QWidget
{
    Q_OBJECT

    public:
        enum VerbosityLevel { Normal = 0, Debug };

        explicit LogWidget();

        ~LogWidget();
        VerbosityLevel verbosityLevel() const;
    public slots:
        void writeToLog(const QString& sysid, const QString& _msg,
            VerbosityLevel vLevel = Normal);
        void setVerbosityLevel(LogWidget::VerbosityLevel vLevel);
    protected:
        void showEvent(QShowEvent *evt);
        void closeEvent(QCloseEvent *evt);
    private slots:
        void setVerbosityLevel(const QString& lvlInStr);
        void updateVerbosityLevelComboBox();
        void saveToFile();
        void showSettings();
        void readGeneralSettings();
        void readWindowSettings();
    private:
        Ui::LogWidget ui;
        VerbosityLevel mVerbosityLevel;
        
        static const QString MessageEndString;

};

#endif
